package com.web.dao.impl;

import com.web.dao.UserDAO;
import com.web.entity.User;
import com.web.util.JDBCUtils;

import java.util.List;

/**
 * @author lenovo
 * @Description
 * @Date2025-2-28 15:34
 * 用户数据访问接口实现
 */
public class UserDAOImpl implements UserDAO {
    @Override
    public User selectUserByUsername(String username){
        List<User> users = JDBCUtils.query(User.class,"select* from t_user where username = ? ",username);
        if(users.size()>0){
            return users.get(0);
        }else {
            return null;
        }

    }
    @Override
    public void updateUser(User user) {
        JDBCUtils.update("update t_user set nickname=?,icon=?,email=? where id = ?",
                user.getNickname(),user.getIcon(),user.getEmail(),user.getId());
    }

}
